package com.cg.design.graphicdesignpattern.observer;

import java.util.Random;

/**
 * 表示生成随机数的类，是NumberGenerator的子类
 *
 * @program: LeetCode->RandomNumberGenerator
 * @description: 表示生成随机数的类，是NumberGenerator的子类
 * @author: cg
 * @create: 2022-03-29 21:34
 **/
public class RandomNumberGenerator extends NumberGenerator {

    /**
     * 随机数生成器
     */
    private final Random random = new Random();

    /**
     *当前数值
     */
    private int number;

    @Override
    public int getNumber() {
        return number;
    }

    @Override
    public void execute() {
        for (int i = 0; i < 20; i++) {
            number = random.nextInt(50);
            notifyObserves();
        }
    }
}
